package round77;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * User: Samuel
 * Date: 07-08-11
 * Time: 02:20 PM
 */
public class D {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String split[] = in.readLine().split(" ");
        int N = Integer.parseInt(split[0]);
        int M = Integer.parseInt(split[1]);
        split = in.readLine().split(" ");
        int x = Integer.parseInt(split[0]);
        int y = Integer.parseInt(split[1]);

        int u[] = new int[M];
        int v[] = new int[M];
        int w[] = new int[M];

        int t[] = new int[N];
        int c[] = new int[N];

        for (int i = 0; i < M; i++) {
            split = in.readLine().split(" ");
            u[i] = Integer.parseInt(split[0]);
            v[i] = Integer.parseInt(split[1]);
            w[i] = Integer.parseInt(split[2]);
        }

        for (int i = 0; i < N; i++) {
            split = in.readLine().split(" ");
            t[i] = Integer.parseInt(split[0]);
            c[i] = Integer.parseInt(split[1]);
        }
        
        
    }
}
